import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * @author vivi
 * @description
 * @date 2024/5/23
 */
public class demo2 {
    public static int N = 48;
    public static int n = 0, m = 0;
    public static int x1 = 0, y1 = 0; // 起始位置
    public static char[][] arr = new char[N][N];
    public static int[][] dist = new int[N][N];
    public static int[] dx = {0, 0, 1, -1};
    public static int[] dy = {1, -1, 0, 0};

    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        m = scanner.nextInt();

        for (int i = 0; i < n; i++) {
            char[] tmp = scanner.next().toCharArray();
            for(int j = 0; j < m; j++)
            {
                arr[i][j] = tmp[j];
                if(arr[i][j] == 'k')
                {
                    x1 = i; y1 = j;
                }
            }

        }

        bfs();

        int count = 0; // 可选择出口数量
        int ret = Integer.MAX_VALUE; // 最小路径长度
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (arr[i][j] == 'e' && dist[i][j] != -1) {
                    count++;
                    ret = Math.min(ret, dist[i][j]);
                }
            }
        }
        if (count == 0) {
            System.out.println("-1");
        }else {
            System.out.println(count + " " + ret);
        }


    }

    public static void bfs() {
        // 1 初始化 dist 为 -1
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                dist[i][j] = -1;
            }
        }
        // 2 创建一个队列， 存放路径
        Queue<int[]> queue = new LinkedList<>();
        queue.add(new int[]{x1, y1});
        dist[x1][y1] = 0;
        // 3 记录
        while (! queue.isEmpty()) {
            int[] tmp = queue.poll();
            int a = tmp[0], b = tmp[1];
            for (int i = 0; i < 4; i++) {
                int x = a + dx[i], y = b + dy[i];
                if (x >= 0 && x < n && y >= 0 && y < m && arr[x][y] != '*' &&
                        dist[x][y] == -1) {
                    dist[x][y] = dist[a][b] + 1;
                    if (arr[x][y] != 'e') {
                        queue.add(new int[] {x, y});
                    }
                }
            }
        }
    }
}
